﻿<UserControl  x:Class="DemoNYTimes.CampaignFinancePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
    xmlns:nyt="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit"
    xmlns:nytvc="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    >
    <UserControl.Resources>
        <nyt:CandidateSummaries x:Key="CandidateSummaries"/>
        <nytvc:NumericFormatConverter x:Key="NumericFormatConverter"/>
        <nytvc:DateTimeConverter x:Key="DateTimeConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White" 
          DataContext="{StaticResource CandidateSummaries}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <data:DataGrid x:Name="Candidates" ItemsSource="{Binding Results}" 
                       AutoGenerateColumns="False" IsReadOnly="True">
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
                <data:DataGridTextColumn Header="Party" Binding="{Binding Party}"/>
                <data:DataGridTextColumn Header="Total Receipts" 
                    Binding="{Binding TotalReceipts, Converter={StaticResource NumericFormatConverter}, ConverterParameter=C}"/>
                <data:DataGridTextColumn Header="Total Disbursements" 
                    Binding="{Binding TotalDisbursements, Converter={StaticResource NumericFormatConverter}, ConverterParameter=C}"/>
                <data:DataGridTextColumn Header="Date Coverage To" 
                    Binding="{Binding DateCoverageTo, Converter={StaticResource DateTimeConverter}, ConverterParameter=d}"/>
            </data:DataGrid.Columns>
        </data:DataGrid>
        <TextBlock Text="{Binding Copyright}" Grid.Row="1"/>
    </Grid>
</UserControl>
